var total,total_arr1;
      function init() {
          total = 100000000;
          total_arr1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
          for (var k = 0; k < 9; k++) {
              for (var j = 1; j < 10; j++) {


                  $("em[t=" + j + "]:eq(" + k + ")").fadeOut();
              }
          }
      }
      function flush() {


          var one = total % 10;                        //个位
          var two = Math.floor(total % 100 / 10);     //十位
          var thr = Math.floor(total % 1000 / 100);           //百位
          var fou = Math.floor(total % 10000 / 1000);            //千位
          var fiv = Math.floor(total % 100000 / 10000);          //万位
          var six = Math.floor(total % 1000000 / 100000);          //十万位
          var sev = Math.floor(total % 10000000 / 1000000);              //
          var eig = Math.floor(total % 100000000 / 10000000);
          var nig = Math.floor(total % 1000000000 / 100000000);
          var arr = [one, two, thr, fou, fiv, six, sev, eig, nig];      //用一数组将这九个数字表示的九个位存起来,从左至右依次个位。。。




          for (var i = 0; i < 9; i++) {


              switch (arr[i]) {
                  case 1:
                       while(total_arr1[i]!=1){                           //用arr1保存的当前位的数字，当与新的数字不同时，从当前数字开始依次递增翻转数字，直到匹配时停止遍历
                           $("em[t="+total_arr1[i]+"]:eq("+i+")").fadeOut();
                           total_arr1[i]=(total_arr1[i]+1)%10;
                           $("em[t="+total_arr1[i]+"]:eq("+i+")").slideToggle();
                       }


                      break;
                  case 2:
                      while(total_arr1[i]!=2){
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").fadeOut();
                          total_arr1[i]=(total_arr1[i]+1)%10;
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").slideToggle();
                      }
                      break;
                  case 3:
                      while(total_arr1[i]!=3){
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").fadeOut();
                          total_arr1[i]=(total_arr1[i]+1)%10;
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").slideToggle();
                      }
                      break;
                  case 4:
                      while(total_arr1[i]!=4){
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").fadeOut();
                          total_arr1[i]=(total_arr1[i]+1)%10;
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").slideToggle();
                      }                                //将当次的数字编号保存进数组arr1[i]中
                      break;
                  case 5:
                      while(total_arr1[i]!=5){
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").fadeOut();
                          total_arr1[i]=(total_arr1[i]+1)%10;
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").slideToggle();
                      }
                      break;
                  case 6:
                      while(total_arr1[i]!=6){
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").fadeOut();
                          total_arr1[i]=(total_arr1[i]+1)%10;
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").slideToggle();
                      }
                      break;
                  case 7:
                      while(total_arr1[i]!=7){
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").fadeOut();
                          total_arr1[i]=(total_arr1[i]+1)%10;
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").slideToggle();
                      }
                      break;
                  case 8:
                      while(total_arr1[i]!=8){
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").fadeOut();
                          total_arr1[i]=(total_arr1[i]+1)%10;
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").slideToggle();
                      }
                      break;
                  case 9:
                      while(total_arr1[i]!=9){
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").fadeOut();
                          total_arr1[i]=(total_arr1[i]+1)%10;
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").slideToggle();
                      }
                      break;
                  case 0:
                      while(total_arr1[i]!=0){
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").fadeOut();
                          total_arr1[i]=(total_arr1[i]+1)%10;
                          $("em[t="+total_arr1[i]+"]:eq("+i+")").slideToggle();
                      }
                      break;
                  default :
                      break;
              }
          }
      }


      function add(){
          total++;
          if(total==999999999){
              total=0;
          }
      }


   $(document).ready(function(){
        init();
       window.setInterval('add()',100);
      var result=window.setInterval('flush()',2000);
  });